/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package integracion;

import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;
import dominio.ConsultaInsumos;
import java.io.IOException;
import java.io.Reader;
import java.sql.SQLException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Maya
 */
public class ControlConsultaInsumos {

    private SqlMapClient sqlMap;

    public ControlConsultaInsumos() throws IOException, SQLException {
        String resource = "configuracion/sql-map-config.xml";
        Reader reader = Resources.getResourceAsReader(resource);
        this.sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
    }

    public List<ConsultaInsumos> consultarInsumos(){

        try{

            List insumos = sqlMap.queryForList("consultarQueryInsumos");
            return insumos;

        } catch (SQLException e){
            Logger.getLogger(ConsultaInsumos.class.getName()).log(Level.SEVERE,null,e);
            return null;
        }

    }

}
